package com.lunwen.lunwen.api;

import com.lunwen.lunwen.bean.MuBan;
import com.lunwen.lunwen.bean.MuBanRenWuRiZhi;
import com.lunwen.lunwen.bean.Result;
import com.lunwen.lunwen.services.MuBanRenWuRiZhiService;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (MuBanRenWuRiZhi)表控制层
 *
 * @author makejava
 * @since 2020-07-24 15:27:09
 */
@RestController
@RequestMapping("api")
public class MuBanRenWuRiZhiController {

    /**
     * 服务对象
     */
    @Autowired
    private MuBanRenWuRiZhiService muBanRenWuRiZhiService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping("selectonemubanrenwurizhi")
    public Result selectOneMuBanRenWuRiZhi(@RequestParam("id") Long id) {
        Result result = new Result();
        MuBanRenWuRiZhi muBanRenWuRiZhi = muBanRenWuRiZhiService.queryById(id);
        result.setResult("200","查询成功",muBanRenWuRiZhi);
        return result;
    }

    @RequestMapping("selectallmubanrenwurizhi")
    public Result selectAllMuBanRenWuRiZhi(@RequestParam("yeMa") Integer yeMa) {
        Result result = new Result();
        int limit = 10;
        int zongGeShu = muBanRenWuRiZhiService.queryCount();
        int xiaBiao = (yeMa - 1) * limit;
        int zongYeMa = (zongGeShu - 1) / limit + 1;
        List<MuBanRenWuRiZhi> muBanRenWuRiZhis = muBanRenWuRiZhiService.queryAllByLimit(xiaBiao, limit);
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("zongGeShu", zongGeShu);
        map.put("zongYeMa", zongYeMa);
        map.put("list", muBanRenWuRiZhis);
        result.setResult("200","查询成功！",map);
        return result;
    }

}